#include "anry-stock-config.h"
#include "anry-stock-retrieve-panel.h"
#include "anry-stock-frame.h"

BEGIN_EVENT_TABLE(AnryStockFrame, wxFrame)
    EVT_MENU(ID_Quit,  AnryStockFrame::OnQuit)
    EVT_MENU(ID_About, AnryStockFrame::OnAbout)
END_EVENT_TABLE()


AnryStockFrame::AnryStockFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
       : wxFrame(NULL, -1, title, pos, size)
{
	///////////////////////////////////////////////////////////////////////////////
	// Set Menu
	///////////////////////////////////////////////////////////////////////////////
    wxMenu *menuFile = new wxMenu;

    menuFile->Append( ID_About, _("&About...") );
    menuFile->AppendSeparator();
    menuFile->Append( ID_Quit, _("E&xit") );

    wxMenuBar *menuBar = new wxMenuBar;
    menuBar->Append( menuFile, _("&File") );

    SetMenuBar( menuBar );
    ///////////////////////////////////////////////////////////////////////////////

	///////////////////////////////////////////////////////////////////////////////
    // books creation
    ///////////////////////////////////////////////////////////////////////////////
    m_sizerFrame = new wxBoxSizer(wxVERTICAL);
    m_panel    = new wxPanel(this);
    m_bookCtrl = new wxNotebook(m_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0);
	m_bookCtrl->Hide();
	
    // Create and add some panels to the notebook
    wxPanel *panel = new AnryStockRetrievePanel(m_bookCtrl);
    m_bookCtrl->AddPage( panel, "Retrieve", false, -1 );
    m_bookCtrl->SetSelection(0);
	m_sizerFrame->Insert(0, m_bookCtrl, wxSizerFlags(5).Expand().Border());
    m_sizerFrame->Show(m_bookCtrl);
    m_sizerFrame->Layout();
	m_panel->SetSizer(m_sizerFrame);
    m_panel->Layout();
    ///////////////////////////////////////////////////////////////////////////////

    //wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
    //sizer->Add(m_panel, wxSizerFlags(1).Expand());
    //SetSizerAndFit(sizer);
    

    CreateStatusBar();
    SetStatusText( _("Welcome to wxWidgets!") );
}

AnryStockFrame::~AnryStockFrame()
{
}

void AnryStockFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
{
    Close(true);
}

void AnryStockFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
{
    wxMessageBox( _("This is a wxWidgets Hello world sample"),
                  _("About Hello World"),
                  wxOK | wxICON_INFORMATION, this );
}
